package com.ruoyi.ruoyiqywechat.service.qywechat.impl;

import com.ruoyi.ruoyiqywechat.service.qywechat.QyMessageService;
import com.ruoyi.ruoyiqywechat.service.qywechat.common.QyCommon;
import com.ruoyi.system.api.RemoteQYMessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;

import java.util.HashMap;

@Service
public class QyMessageServiceImpl extends QyCommon implements QyMessageService {
    @Lazy
    @Autowired
    private RemoteQYMessageService remoteQYMessageService;


    @Value("${guid}")
    private String guid;

    /**
     * 发送小程序
     * @param data
     * @return
     */
    public String send_weapp(HashMap<String,Object> data){
        data.put("guid",guid);
        super.stringObjectHashMap.put("path","/msg/send_weapp");
        super.stringObjectHashMap.put("data",data);
        return remoteQYMessageService.send(stringObjectHashMap);
    }
    /**
     * 发送公众号
     * @param data
     * @return
     */
    public String send_gh(HashMap<String,Object> data){
        data.put("guid",guid);
        super.stringObjectHashMap.put("path","/msg/send_link");
        super.stringObjectHashMap.put("data",data);
        return remoteQYMessageService.send(stringObjectHashMap);
    }
    /**
     * 发送私聊信息
     * @param data
     * @return
     */
    public String send_private(HashMap<String,Object> data){
        data.put("guid",guid);
        super.stringObjectHashMap.put("path","/msg/send_text");
        super.stringObjectHashMap.put("data",data);
        return remoteQYMessageService.send(stringObjectHashMap);
    }
}
